<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #container {
        height: 300px;
        overflow-y: scroll;
        scroll-timeline: --squareTimeline y;
        position: relative;
        background-color: antiquewhite;
      }

      #square {
        background-color: deeppink;
        width: 100px;
        height: 100px;
        animation-name: rotateAnimation;
        animation-timeline: --squareTimeline;
        position: absolute;
        bottom: 0;
      }

      #stretcher {
        height: 600px;
        background: #dedede;
      }

      @keyframes rotateAnimation {
        from {
          transform: rotate(0deg);
        }

        to {
          transform: rotate(360deg);
        }
      }
    </style>
  </head>
  <body>
    <div id="container">
      <div id="square"></div>
      <div id="stretcher"></div>
    </div>
  </body>
</html>
